
//current: 
var NativeModules = {
    "testFunc": (num) => {
        console.log("calc sum: 1 + .. + ", num);
        var sum = 0;
        for (var i = 1; i < num; i++) {
            sum += i;
        }
        console.log("sum: ", sum);
    }
}
globalThis.NativeModules = NativeModules;

(function () {
    globalThis = new Function("return this")();
    const bridge = {
        invoke: (func_num, args) => {
            return globalThis.NativeModules[func_num](args);
        }
    };
    globalThis.bridge = bridge;
})();

globalThis.bridge.invoke("testFunc", 4);

// we have
var NativeModules = {
    "module1": {
        "testFunc": (num) => {
            console.log("calc sum: 1 + .. + ", num);
            var sum = 0;
            for (var i = 1; i < num; i++) {
                sum += i;
            }
            console.log("sum: ", sum);
        }
    }
}
globalThis.NativeModules = NativeModules;

(function () {
    globalThis = new Function("return this")();
    function invoke(module_name, func_name, args) {
        return globalThis.NativeModules[module_name][func_name](args);
    }
    globalThis.invoke = invoke;
})();

globalThis.invoke("module1", "testFunc", 4);

globalThis.NativeModules["module1"]["testFunc"](4);